﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUS;
using System.Collections.Generic;
using DTO;
public partial class MasterPage : System.Web.UI.MasterPage
{
    PanelBUS panelBUS = new PanelBUS();
    ContactInformationBUS contactInfoBUS = new ContactInformationBUS();
    SupportOnlineYMBUS soYMBUS = new SupportOnlineYMBUS();
    SupportOnlineSkypeBUS soSkypeBUS = new SupportOnlineSkypeBUS();
    AccountsBUS accBUS = new AccountsBUS();
    BannerBUS bannerBUS = new BannerBUS();
    PartnerBUS partnerBUS = new PartnerBUS();
    HotLineBUS hotlineBUS = new HotLineBUS();
    protected string shortname;
    protected string webname;
    protected string slogan;
    protected string copyright;
    protected string powered;
    protected string designed;
    protected string website;

    protected List<SupportOnlineYMDTO> soYMList;
    protected List<SupportOnlineSkypeDTO> soSkypeList;

    public List<PanelDTO> panelMainList;

    protected List<BannerDTO> bannerDTO;
    protected List<PartnerDTO> partnerDTO;
    protected List<HotLineDTO> hotlineDTO;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ContactInformationDTO contactInfoList = contactInfoBUS.GetContactInformation();
            webname = contactInfoList.CompanyName;
            slogan = contactInfoList.Slogan;
            shortname = contactInfoList.ShortName;
            copyright = contactInfoList.Copyright;
            powered = contactInfoList.Powered;
            designed = contactInfoList.Designed;
            website = contactInfoList.Website;

            soYMList = soYMBUS.GetAllSupportOnlineYMs();
            soSkypeList = soSkypeBUS.GetAllSupportOnlineSkypes();

            panelMainList = panelBUS.GetActiveMainPanels(1);
            panel1Name.Text = "Tin Tức";

            RadAjaxLoadingPanel1.BackgroundPosition = Telerik.Web.UI.AjaxLoadingPanelBackgroundPosition.Center;
            RadAjaxLoadingPanel1.AnimationDuration = 1000;

            bannerDTO = bannerBUS.GetActiveBanner();
            partnerDTO = partnerBUS.GetActivePartner();
            hotlineDTO = hotlineBUS.GetAllHotLines();
        }
    }

    protected List<PanelDTO> GetSubPanel(int? mainPanelID)
    {
        List<PanelDTO> panelSubList = panelBUS.GetActiveSubPanels(mainPanelID);
        return panelSubList;
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string un = Request.Form["txtUName"];
        string pa = Request.Form["txtPword"]; 
        AccountDTO acc = accBUS.Login(un, pa);
        if (acc == null)
        {
            Session.Clear();
            return;
        }
        Session["uname"] = acc.UserName;
    }

    protected void btnLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
    }
}

